package com.itheima.cncom;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Server {
    public static void main(String[] args) throws IOException {
        //找到对应的基站
        DatagramSocket datagramSocket = new DatagramSocket(10100);
        //从基站中得到东西放入自己的包中
        byte[] bytes = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length);
        //接收包
        datagramSocket.receive(datagramPacket);
        //将包中的数据取出
        byte[] data = datagramPacket.getData();
        System.out.println(new String(data));
        datagramSocket.close();
    }
}
